import actionTypes from "./actionTypes";
import * as todoFn from './todo';

function todoReducer(state, action) {
  const { type, payload } = action;

  switch (type) {
    case actionTypes.ADD_TODO:
      todoFn.addTodo(state, payload);
      break;
    case actionTypes.TOGGLE_TODO:
      todoFn.toggleTodo(state, payload);
      break;
    case actionTypes.REMOVE_TODO: 
      todoFn.removeTodo(state, payload);
      break;
    default:
      break;
  }
}

export default todoReducer;
